package org.example.order;

import com.alibaba.csp.sentinel.adapter.servlet.CommonFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;

import javax.servlet.Filter;

// @Configuration
public class SentinelConfig {

    // @Resource
    // private MyBlockExceptionHandler blockExceptionHandler;

    // @Bean
    public FilterRegistrationBean<Filter> sentinelFilterRegistration() {
        FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<>();
        filterRegistrationBean.setFilter(new CommonFilter());
        filterRegistrationBean.addUrlPatterns("/*");
        filterRegistrationBean.addInitParameter(CommonFilter.WEB_CONTEXT_UNIFY, "false");
        filterRegistrationBean.setName("sentinelFilter");
        filterRegistrationBean.setOrder(1);

        // WebCallbackManager.setUrlBlockHandler(blockExceptionHandler);
        // WebCallbackManager.setRequestOriginParser(new MyRequestOriginParse());

        return filterRegistrationBean;
    }

}